﻿@using NewLife.Cube;
@using XCode.Configuration;
@{
    //var entity = Model as IEntity;
    //var fact = EntityFactory.CreateOperate(entity.GetType());
    //var fields = ViewBag.Fields as IList<FieldItem>;

    //var set = NewLife.Cube.Setting.Current;
    //var cls = set.FormGroupClass;
    //if (cls.IsNullOrEmpty()) { cls = "form-group col-xs-12 col-sm-6 col-lg-4"; }

    //var total = 12;
    //var label = 4;
    //var span = 0;
    //var input = total - label - span;

    //var cid = fact.Table.FindByName("CreateUserID") as FieldItem;
    //var uid = fact.Table.FindByName("UpdateUserID") as FieldItem;
    //var cip = fact.Table.FindByName("CreateIP") as FieldItem;
    //var uip = fact.Table.FindByName("UpdateIP") as FieldItem;
    //var remark = fact.Table.FindByName("Remark") as FieldItem;
    //if (remark == null) { remark = fact.Table.FindByName("Description"); }

    //var hasUser = cid != null || uid != null;
    //if (hasUser && ViewData["Provider"] == null) { ViewData["Provider"] = ManageProvider.Provider; }
    //var provider = ViewData["Provider"] as IManageProvider;
}
@*@if (cid != null && !fields.Contains(cid))
    {
        var user = fact.Table.FindByName("CreateUserID") as FieldItem;
        var time = fact.Table.FindByName("CreateTime") as FieldItem;
        <div class="form-group col-xs-12 col-sm-6">
            <label class="control-label col-xs-@label col-sm-@label">创建</label>
            <div class="control-label col-xs-@(total - label) col-sm-@input" style="text-align: left;">
                @if (user != null)
                {
                    var val = entity[user.Name];
                    <span class="text-primary" title="@val">@provider.FindByID(val)</span>
                }
                @if (time != null)
                {
                    var dt = (DateTime)entity[time.Name];
                    <span class="text-success">@dt.ToFullString()</span>
                }
                @if (cip != null)
                {
                    var ip = entity[cip.Name] + "";
                    <span class="text-primary">@ip @ip.IPToAddress()</span>
                }
            </div>
        </div>
    }
    @if (uid != null && !fields.Contains(uid))
    {
        var user = fact.Table.FindByName("UpdateUserID") as FieldItem;
        var time = fact.Table.FindByName("UpdateTime") as FieldItem;
        <div class="form-group col-xs-12 col-sm-6">
            <label class="control-label col-xs-@label col-sm-@label">更新</label>
            <div class="control-label col-xs-@(total - label) col-sm-@input" style="text-align: left;">
                @if (user != null)
                {
                    var val = entity[user.Name];
                    <span class="text-primary" title="@val">@provider.FindByID(val)</span>
                }
                @if (time != null)
                {
                    var dt = (DateTime)entity[time.Name];
                    <span class="text-success">@dt.ToFullString()</span>
                }
                @if (uip != null)
                {
                    var ip = entity[uip.Name] + "";
                    <span class="text-primary">@ip @ip.IPToAddress()</span>
                }
            </div>
        </div>
    }
    @if (remark != null && !fields.Contains(remark))
    {
        <div class="form-group col-md-12">
            <label class="control-label col-md-2">@remark.DisplayName</label>
            <div class="input-group col-md-8">
                @Html.ForString(remark.Name, (String)entity[remark.Name], -1)
                @Html.ForDescription(remark)
            </div>
        </div>
    }*@